import request from "@/utils/request"
import {
    LoginParams,
    LoginRes,
    SendCodeRes,
    MemberCountRes,
    SaveRes,
    SaveParams,
    QueryParams,
    QueryRes, DeleteByIdRes
} from "@/api/member/type";

/**
 * 登录
 * @param params
 */
export function login(params: LoginParams): Promise<LoginRes> {
    return request.post(`/member/member/login`, params);
}

export function sendCode(mobile: string): Promise<SendCodeRes> {
    return request.get(`/member/member/sendCode?mobile=${mobile}`);
}

/**
 * 会员总数
 * @returns
 */
export function memberCount(): Promise<MemberCountRes> {
    return request.get(`/member/member/count`);
}

/**
 * save_1
 * @param {object} params TicketSaveReq
 * @param {number} params.id
 * @param {number} params.memberId
 * @param {number} params.passengerId
 * @param {string} params.passengerName
 * @param {object} params.trainDate
 * @param {string} params.trainCode
 * @param {number} params.carriageIndex
 * @param {string} params.seatRow
 * @param {string} params.seatCol
 * @param {string} params.startStation
 * @param {object} params.startTime
 * @param {string} params.endStation
 * @param {object} params.endTime
 * @param {string} params.seatType
 * @param {object} params.createTime
 * @param {object} params.updateTime
 * @returns
 */
export function save(params: SaveParams): Promise<SaveRes> {
    return request.post(`/member/admin/ticket/save`, params);
}

/**
 * query
 * @param {object} params TicketQueryReq
 * @param {number} params.pageNum
 * @param {number} params.pageSize
 * @returns
 */
export function query(params: QueryParams): Promise<QueryRes> {
    return request.post(`/member/admin/ticket/query-list`, params);
}

/**
 * deleteById
 * @param {string} id
 * @returns
 */
export function deleteById(id: number): Promise<DeleteByIdRes> {
    return request.delete(`/member/admin/ticket/delete/${id}`);
}